# Maintainer: Jonas Witschel <diabonas@archlinux.org>
pkgname=libtpms
pkgver=0.9.5
_tag=6bce05ee809bb6e5e30e12e69edbf64f48ad20aa # git rev-parse "v$pkgver"
pkgrel=2
pkgdesc='Library providing a software emulation of a Trusted Platform Module (TPM 1.2 and TPM 2.0)'
arch=('loong64' 'x86_64')
url='https://github.com/stefanberger/libtpms'
license=('BSD')
depends=('openssl')
makedepends=('git')
options=('debug')
source=("git+$url.git?signed#tag=$_tag")
sha512sums=('SKIP')
validpgpkeys=('B818B9CADF9089C2D5CEC66B75AD65802A0B4211') # Stefan Berger <stefanb@linux.vnet.ibm.com>

pkgver() {
	cd "$pkgname"
	git describe | sed 's/^v//;s/\([^-]*-\)g/r\1/;s/-/./g'
}

prepare() {
	cd "$pkgname"
	autoreconf --install --force
}

build() {
	cd "$pkgname"
	./configure --prefix=/usr --with-openssl --with-tpm2
	make
}

check() {
	cd "$pkgname"
	make check
}

package() {
	cd "$pkgname"
	make DESTDIR="$pkgdir" install
	install -Dm644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname"
}
